const axios = require('axios')

module.exports.getItems = async (goods_id) => {
	const url = `https://buff.163.com/api/market/goods/sell_order?game=dota2&goods_id=${goods_id}&page_num=1&sort_by=default&mode=&allow_tradable_cooldown=1`
	try {
		const resp = await axios.get(url)
		const goods_data = resp.data.data
		let goodsName = goods_data.goods_infos[goods_id].name
		let goodsLowPrice = resp.data.data.items[0].price
		return `查询商品价格成功，${goodsName}的最低价格为：${goodsLowPrice}`
	} catch (error) {
		return `查询商品价格失败，错误信息：${JSON.stringify(err)}`
	}
}
